<?php

	$selTour = "";
	$selCity = "";
	$selStation = "";
	$stationPic;
	$text;$pic;$header;
	
	if(isset($_GET['tour']) ){
		$selTour = $_GET['tour'];
	}
	if(isset($_GET['city']) ){
		$selCity= $_GET['city'];
	}
	
	if(isset($_GET['station']) ){
		$selStation= $_GET['station'];
	}
	
	function getSelectedStation(){
		global $selStation;
		getStation($selStation);
	}
	
	function getStation($selStation){
	
	global $stationPic,$text,$pic,$header;
	// Datenbankverbindung aufbauen
	$db = new mysqli('localhost', 'root', '', 'cityguide');
	$db->set_charset("utf8");
	if (mysqli_connect_errno()) {
    	printf("Connect failed: %s\n", mysqli_connect_error());
    	exit();
	}
	$query = "SELECT distinct SIGHT.name, SIGHT.details, SIGHT.pic FROM SIGHT where SIGHT.s_id = ?";

	if ($stmt = $db->prepare($query)) {
		$stmt->bind_param('s', $selStation); # sind die Parameter die mit ? vordefiniert sind
		$stmt->execute();
    	$stmt->bind_result($name,$text,$pic);
    	
    	while ($row = $stmt->fetch()) {
    			
			$text = $text;
			$header = $name;
			$pic = $pic;
			  		
    	}	
    	// Statement schliessen
		$stmt->close();
	}
	// Datenbankverbindung schliesssen
	$db->close();	
}
?>